package com.xinfu.newproject.base;

import android.app.Application;
import android.content.Context;
import android.util.Log;

import androidx.multidex.MultiDex;

import com.tencent.bugly.crashreport.CrashReport;
import com.tencent.smtt.sdk.QbSdk;
import com.xinfu.newproject.test.DisplayToast;

public class ChangEApplication extends Application {

    private static Application instance;

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;

        // 初始化MultiDex
        MultiDex.install(this);
        initTBS();
        CrashReport.initCrashReport(getApplicationContext(), "397db08720", true);
        //Toast初始化
        DisplayToast.getInstance().init(getApplicationContext());

    }

    private void initTBS() {
        //初始化X5内核
        QbSdk.initX5Environment(instance, new QbSdk.PreInitCallback() {
            @Override
            public void onCoreInitFinished() {
                //x5内核初始化完成回调接口，此接口回调并表示已经加载起来了x5，有可能特殊情况下x5内核加载失败，切换到系统内核。
                Log.e("@@", "加载内核是否成功:");
            }

            @Override
            public void onViewInitFinished(boolean b) {
                //x5內核初始化完成的回调，为true表示x5内核加载成功，否则表示x5内核加载失败，会自动切换到系统内核。
                Log.e("@@", "加载内核是否成功:" + b);
            }
        });
    }


    public static Context getAppContext() {
        return instance;
    }

}
